package com.gomoku;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.*;

public class GobangMain {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            new MainMenu().setVisible(true);
        });
    }
}

class MainMenu extends JFrame {
    public MainMenu() {
        setTitle("五子棋游戏 - 主菜单");
        setSize(400, 300);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);
        setResizable(false);

        JPanel panel = new JPanel(new GridLayout(4, 1, 10, 10));
        panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

        JButton twoPlayerBtn = new JButton("双人对战");
        JButton aiBtn = new JButton("人机对战");
        JButton onlineBtn = new JButton("联机对战");
        JButton replayBtn = new JButton("游戏记录与回放");
        JButton exitBtn = new JButton("退出游戏");

        twoPlayerBtn.addActionListener(e -> {
            dispose();
            new GameFrame(GameMode.TWO_PLAYER).setVisible(true);
        });

        aiBtn.addActionListener(e -> {
            dispose();
            new GameFrame(GameMode.HUMAN_VS_AI).setVisible(true);
        });

        onlineBtn.addActionListener(e -> {
            dispose();
            new OnlineMenu().setVisible(true);
        });

        replayBtn.addActionListener(e -> {
            dispose();
            new ReplayMenu().setVisible(true);
        });

        exitBtn.addActionListener(e -> System.exit(0));

        panel.add(twoPlayerBtn);
        panel.add(aiBtn);
        panel.add(onlineBtn);
        panel.add(replayBtn);
        panel.add(exitBtn);

        add(panel);
    }
}